

function err_user_head(obj,t){
	//event.preventDefault();
	if(t==1){
		obj.src="/static/images/user_head.jpg.small.jpg";
	}else{
		obj.src="/static/images/user_head.jpg.100x100.jpg";
	}
	
}
function err_imgurl(obj,t){
	//event.preventDefault();
	if(t==1){
		obj.src="/static/images/no_image.jpg.small.jpg";
	}else if(t==2){
		obj.src="/static/images/no_image.jpg.middle.jpg";
	}else{
		obj.src="/static/images/no_image.jpg.100x100.jpg";
	}
}
$(document).ready(function(){
	//删除
	$(".delete").click(function(){
		var obj=$(this);
		if(confirm("删除后不可恢复，确认删除吗?")){
			$.get($(this).attr("url"),function(data){
				if(data.error=='0'){
					obj.parents("tr").remove();
				}else{
					alert(data.message);
				}
			},"json");
			
		}
	});
	
	$(document).on("click",".ajax_yes",function()
	{
		
		$.get($(this).attr("url"));
		$(this).attr("src","static/images/yes.gif");
		var url=$(this).attr("url");
		$(this).attr("url",$(this).attr("rurl"));
		$(this).attr("rurl",url);
		$(this).removeClass("ajax_yes").addClass("ajax_no");
	});
	
	$(document).on("click",".ajax_no",function()
	{
		$.get($(this).attr("url"));
		$(this).attr("src","static/images/no.gif");
		var url=$(this).attr("url");
		$(this).attr("url",$(this).attr("rurl"));
		$(this).attr("rurl",url);
		$(this).removeClass("ajax_no").addClass("ajax_yes");
	});
	
 
	$(document).on("change","#ajax_catid",function(){
		var pid=$(this).val();
		if(pid!="0"){
			$.get($(this).attr("url"),{pid:$(this).val()},function(data){
				$("#ajax_catid_2nd").empty().append(data).show();					 
			});
		}else{
			$("#ajax_catid_2nd").empty().hide();
			if($("#ajax_catid_3nd")){$("#ajax_catid_3nd").hide().empty();}
		}
	})
	
	$(document).on("change","#ajax_catid_2nd",function(){
		var pid=$(this).val();
		if(pid!="0"){
			$.get($(this).attr("url"),{pid:pid},function(data){
				$("#ajax_catid_3nd").empty().append(data).show();
			});
		}else{
			$("#ajax_catid_3nd").hide().empty();
		}
	})
	
	//$("tr:nth-child(1)").addClass('first'); 
	//$('tr').addClass('success'); 
	$('tr:odd').addClass('info'); //奇偶变色，添加样式 
	
	
});